package org.familysearch.fsapi.gwt.server.dao.rest;

import org.familysearch.fsapi.gwt.server.dao.DAOFactory;
import org.familysearch.fsapi.gwt.server.dao.IdentityDAO;
import org.familysearch.fsapi.gwt.server.dao.PersonDAO;
import org.familysearch.fsapi.gwt.server.dao.TempleDAO;

public class RESTDAOFactory extends DAOFactory {

	public PersonDAO getPersonDAO()
	{
		return (PersonDAO)instantiateDAO(PersonDAOREST.class);
	}

    public TempleDAO getTempleDAO()
    {
    	return (TempleDAO)instantiateDAO(TempleDAOREST.class);
    }

    public IdentityDAO getIdentityDAO()
    {
    	return (IdentityDAO)instantiateDAO(IdentityDAOREST.class);
    }
    
    private GenericRESTDAO instantiateDAO(Class daoClass) {
        try {
            return (GenericRESTDAO)daoClass.newInstance();
        } catch (Exception ex) {
            throw new RuntimeException("Cannot instantiate DAO: " + daoClass, ex);
        }
    }


    
}
